﻿
using MyTask = System.Threading.Tasks;//修改命名空间
//using MyConsole = System.Console;


using TestUsing = _14_using关键字用法以及在Dispose中的应用.Student;
using TestStudent_ = TestStudent.Student;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;

namespace _14_using关键字用法以及在Dispose中的应用
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.Title = "C#using关键字用法";

            //MyTask.Task task = new Task(() =>
            //{
            //    Console.WriteLine("MyTask任务");
            //});
            //task.Start();
            //MyConsole.WriteLine("MyConsole运行");

            //TestUsing.Show();
            //TestStudent_.Show();

            //释放资源
            //需要继承IDisposible
            MemoryStream ms = new MemoryStream();
            //using (ms)
            //{
            //    BinaryFormatter formatter=new BinaryFormatter();
            //    formatter.Serialize(ms, args);
            //}
            //try
            //{
            //    BinaryFormatter formatter = new BinaryFormatter();
            //    formatter.Serialize(ms, args);
            //}
            //finally {
            //    ms.Dispose();
            //}

            using (Teacher teacher = new Teacher())//可以放多个但是只能放一种类型
            {
                teacher.Show();
            }

            Console.ReadKey();
        }
    }
}
